<!doctype html>
<html xmlns:th="http://www.w3.org/1999/xhtml">

<head>
    <th:block th:include="/A0723/include :: header('收支记录')"/>
</head>

<body>
<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 class="mui-title">收支记录</h1>
</header>
<div class="mui-content">
    <!--  -->
    <ul class="record_list">

    </ul>
</div>
<th:block th:include="/A0723/include :: footer"/>
<script type="text/javascript">
    $(function () {
        getAccountRecord()
    })

    //获取账户明细记录
    function getAccountRecord() {
        mui.ajax(ctx+'front/accountRecords', {
            dataType: 'json',//服务器返回json格式数据
            type: 'get',//HTTP请求类型
            timeout: 10000,//超时时间设置为10秒；
            headers: {'Content-Type': 'application/json'},
            success: function (res) {
                //服务器返回响应，根据响应结果
                let data = res.data;
                let str = ''
                $.each(data, function (i, d) {
                    str += '<li>\n' +
                        '<div>用户名：' + d.phone + '</div>\n' +
                        '<div>类型：' + formatterWay(d.way) + '</div>\n' +
                        '<div>备注：' + d.remark + '</div>\n' +
                        '<div>金额：<span class="fu">' + formatterType(d.type) + d.amount
                        + '元</span></div>\n' +
                        '<div>时间：' + d.createTime + '</div>\n' +
                        '</li>'
                })
                $(".record_list").append(str);
            },
            error: function (xhr, type, errorThrown) {
                //异常处理；
                console.log(type);
            }
        });
    }

    /**
     * 明细方式
     * @param type
     * @returns {string}
     */
    function formatterWay(type) {
        return type === 1 ? "点赞" : type === 2 ? "关注" : type === 3 ? "互粉" : type === 4 ? "推荐奖" : type === 5 ? "团队奖" : type === 6 ? "购买套餐" : type === 7 ? "任务金" : '';
    }

    /**
     * 加减,o为减，1为加
     * @param type
     * @returns {string}
     */
    function formatterType(type) {
        return type === 0 ? "-" : type === 1 ? "+" : '';
    }
</script>
</body>

</html>
